﻿<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>jQueryHTML之append()和prepend()</title>
        <script src="js/jquery-3.6.1.min.js"></script>
        <style>
            div {
                width: 200px;
                border: 1px solid silver;
            }
        </style>
    </head>
    <body>
        <h3>jQueryHTML之append()和prepend()</h3>
        <hr>
        <div>jQuery</div>
        <button id="btn01">append()</button>
        <button id="btn02">prepend()</button>
        <script>
            $(document).ready(function() {
				//按钮1的点击事件：在<div>元素内部的结尾处追加内容
                $("#btn01").click(function() {
					$("div").append("<p>Bye!</p>");				
                });
				//按钮2的点击事件：在<div>元素内部的开头处追加内容
                $("#btn02").click(function() {
					$("div").prepend("<p>Hello!</p>");							
                });
            });
        </script>
	</body>
</html>
